//系统参数
var PageSystemTime = {
        id: "PageSystemTime", //页面id
        menu: "i18n.lan.menu.basic", //所属菜单(一级菜单名)
        title: "i18n.lan.menu.PageSystemTime", //标题（二级菜单名）
        icon: "icon-me-setting", //图标
        refreshBtnCmd: "DUMP_CORE", //刷新按钮指令
        saveBtn: true, //保存按钮
        el: [ //控件
            {
                elname: "checkbox",
                label: i18n.lan.PageSystemTime.ntpSyncTime,
                id: "time_ntpSyncTime",
                endRow: true,
                attrs: {
                    dumpKey: "GPRS_NTP",
                    cmdKey: "GPRSNTP",
                }
            },
            {
                elname: "text",
                label: i18n.lan.PageSystemTime.syncTimeNumber,
                endRow: true,
                attrs: { dumpKey: "GSMSP", cmdKey: "GSMSP" },
            },
            {
                elname: "text",
                label: i18n.lan.PageSystemTime.manualSyncTime,
                attrs: { dumpKey: "RTCTIME", title: "yyyy,MM,dd,HH,mm", id: "pageSystemTime_time", placeholder: i18n.lan.PageSystemTime.defaultNowTime },
            },
            {
                elname: "button",
                text: i18n.lan.PageSystemTime.synctime,
                endRow: true,
                attrs: { class: "smallBtn", onclick: "synctime()", title: "RTCTIME" },
            },
            { //设备时区
                elname: "combobox",
                id: "time_deviceTimezone",
                label: i18n.lan.PageSystemTime.deviceTimezone,
                items: "i18n.lan.PageSystemTime.timezoneItems",
                endRow: true,
                attrs: { dumpKey: "SYSTIMEZONE", cmdKey: "TIMEZONE" },
            },
            {
                elname: "datagrid",
                rowCount: Device.getNodesCount("ntpServer"),
                data: {
                    width: 630,
                    columns: [
                        [{
                                field: 'index',
                                width: 40,
                                align: "center",
                            },
                            {
                                field: "IP",
                                editor: Easyui.editor.textbox,
                                dumpKey: "NTPSVR<n>",
                                dumpParamIndex: 0,
                                cmdKey: "NTPSVR<n>,",
                                otherFields: "port,timezone,timeoffset,timertype",
                                width: 150,
                            },
                            {
                                field: "port",
                                editor: Easyui.editor.numberbox,
                                dumpKey: "NTPSVR<n>",
                                dumpParamIndex: 1,
                                width: 100,
                            },
                            {
                                field: "timezone",
                                editor: Easyui.editor.numberbox1,
                                dumpKey: "NTPSVR<n>",
                                dumpParamIndex: 2,
                                width: 100,
                            },
                            {
                                field: "timeoffset",
                                editor: Easyui.editor.numberbox,
                                dumpKey: "NTPSVR<n>",
                                dumpParamIndex: 3,
                                width: 100,
                            },
                            {
                                field: "timertype",
                                formatter: Easyui.formatter.combobox,
                                editor: new Easyui.editor.Combobox(i18n.lan.PageSystemTime.timerTypeItems),
                                dumpKey: "NTPSVR<n>",
                                dumpParamIndex: 4,
                                width: 120,
                            },
                        ]
                    ],
                }
            },
        ],
    }
    //同步时间
function synctime() {
    var textTime = $("#pageSystemTime_time");
    if (textTime && textTime.val() != "") { //使用用户设置的时间
        sendCmd("RTCTIME" + textTime.val());
    } else { //使用电脑时间
        var date = new Date();
        sendCmd("RTCTIME" + date.getFullYear() + "," + (date.getMonth() + 1) + "," + date.getDate() + "," + date.getHours() + "," + date.getMinutes() + "," + date.getSeconds());
    }
}
CmdPage.add(PageSystemTime); //添加到页面管理